import {useState,useEffect} from 'react'
import CamundaAPI from "@/api/CamundaApi.js";
function useProcessDefOptionsHooks(){
    const [processDefList, setProcessDefList] = useState([]);

    const onProcessDefSearch = function (v) {
        const params = {};
        if (v) {
          params.keyWords = v;
        }
        CamundaAPI.queryProcessDefList(params).then((r) => {
          setProcessDefList(
            r.result.map((item) => {
              return {
                text: `${item.defName}(${item.defKey}[Ver.${item.defVersion}])`,
                value: item.procDefId,
              };
            })
          );
        });
      };

      useEffect(() => {
        onProcessDefSearch("");
    
      }, []);

      return {
        processDefList,
        onProcessDefSearch
      }
}

export default useProcessDefOptionsHooks;